package com.wms.utils;

import java.util.Map;

/**
 * @author Yzxxn
 */
public class UserContext {

    private static ThreadLocal<Map<String, Object>> userInfo = new ThreadLocal<>();

    public static Integer getUserId() {
        Map<String, Object> map = userInfo.get();
        return (Integer) map.get("id");
    }

    public static String getName() {
        Map<String, Object> map = userInfo.get();
        return map.get("name").toString();
    }

    public static String getUsername() {
        Map<String, Object> map = userInfo.get();
        return map.get("username").toString();
    }

    public static Map<String, Object> get() {
        return userInfo.get();
    }

    public static void set(Map<String, Object> map) {
        userInfo.set(map);
    }

    public static void remove() {
        userInfo.remove();
    }
}
